package com.sti.framework.models.User.controller;

import com.sti.framework.core.annotation.authorization.Authorization;
import com.sti.framework.core.web.Page;
import com.sti.framework.core.web.ResponseBodyEntity;
import com.sti.framework.core.web.SimplePage;
import com.sti.framework.models.User.data.Authority;
import com.sti.framework.models.User.service.AuthorityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/Api/Authority")
@Api(tags = "用户管理", value = "用户管理")
public class AuthorityController {

    @Inject
    private AuthorityService authorityService;

    @ApiOperation(value = "接口列表", hidden = true)
    @Authorization(value = "/Api/RoleAuthority/Modify", describes = "修改权限", impor = "false")
    @GetMapping("/List")
    public ResponseBodyEntity<SimplePage<Authority>> List(Page page) {
        return ResponseBodyEntity.success(authorityService.getListPage(page));
    }

    @ApiOperation(value = "接口详情", hidden = true)
    @Authorization(value = "/Api/RoleAuthority/Modify", describes = "修改权限", impor = "false")
    @GetMapping("/Info")
    public ResponseBodyEntity<Authority> Info(@Valid @NotNull Long id) {
        return ResponseBodyEntity.success(authorityService.get(id));
    }

}
